<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/jsplib/pubhead.jsp"%>
<%@ page import="net.comm.common.ValueMaping" %>
<%@ taglib uri="/WEB-INF/myTaglib.tld" prefix="tag"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<TITLE>${myfn:getMsg("NOTADV_SORT",theForm.nsort)}${myfn:getMsg("NOTADV_TYPE",theForm.ntype)}管理</TITLE>
	<link rel="stylesheet" type="text/css" href="${cpath}/css/adgloab.css"/>
	<link rel="stylesheet" type="text/css" href="${cpath}/css/adstyle.css" />

	<script type="text/javascript" src="${cpath}/fckeditor/fckeditor.js"></script>
	<SCRIPT src="${cpath}/js/location.js" type=text/javascript></SCRIPT>
	<SCRIPT src="${cpath}/js/location_array.js" type=text/javascript></SCRIPT>
	
</head>
<body>
<script> 
	//转页面
	var curUserID = '${userID}';
	if((curUserID == "")||(curUserID == null)){
//		parent.window.location.replace("${cpath}/index.jsp"); 
	}
</script>

		<DIV id=admin>

		<!-- 右侧宽栏 {{{ -->
		<DIV class=group_mid>
			<div class='subtop' >
				<p><a href="#"><img src="${cpath}/images/slogo.png" ></a></p>
				<dl >
					<dt class="tit"><a href="#">${myfn:getMsg("NOTADV_SORT",theForm.nsort)}${myfn:getMsg("NOTADV_TYPE",theForm.ntype)}管理</a></dt>
					<dd class="intro"><span>&nbsp;</span></dd>
				</dl>
				<div class='fun'>
					<li><a href="javascript:history.go(-1);">返回上一页</a></li>
				</div>
			</div>
			<DIV class='whole'><!-- 右侧宽栏 }}}-->
				<form action="${cpath}/notadv.do" name="theForm"  method="post" enctype="multipart/form-data" >
					<UL class=detailinfo>
						<LI><STRONG>标&nbsp;&nbsp;&nbsp;&nbsp;题:</STRONG><EM>
							<input type="text" name='title' value='${theForm.title}' maxlength="200" class="long"/></EM></LI>
						<LI><STRONG>内&nbsp;&nbsp;&nbsp;&nbsp;容:</STRONG><EM>
							<textarea name="fck" rows="8" cols="40" >${theForm.content}</textarea></EM></LI>
						<LI><STRONG>附件:</STRONG><EM>
							<input type="file" name='filepath' value='' class="long" onchange="check_loadfile(this);" /></EM></LI>
						<!--隐藏域-->
						<input type="hidden" name='action'		value='${theForm.action}'/>
						<input type="hidden" name='f_ID'		value='${theForm.f_ID}'/>
						<input type="hidden" name='content'		value='${theForm.content}'/>
						<input type="hidden" name='ntype'		value='${theForm.ntype}'/>
						<input type="hidden" name='nsort'		value='${theForm.nsort}'/>
						<input type="hidden" name='nsortID'		value='${theForm.nsortID}'/>
						<input type="hidden" name='userID'		value='${theForm.userID}'/>

						<INPUT id=max_file_size type=hidden value=3096152 name=MAX_FILE_SIZE>
						<IMG id=oFileChecker style="WIDTH: 0px; HEIGHT: 0px" onload=check_photo_size()>

					</UL><!--结束 }}}-->
					<UL class=detailinfo>
						<li class=btn>	
							<input type="button" name="save"  id="save" onclick="javascript:doConfirm();" class="shortBtn" value="保   存"/>&nbsp;
							<input type="button" name="cancel"  id="cancel" onclick="javascript:history.go(-1);" class="shortBtn" value="取   消"/>&nbsp;
						</li>
					</UL>
				</form>
			</DIV><!-- whole end }}} -->			

			</DIV><!-- content }}} -->
		</DIV><!-- profile_mid }}} -->
		</DIV><!-- group end }}} -->
<br><br><br>
</body>
</html>
<!---->
<script type="text/javascript">
  var oFCKeditor = new FCKeditor('fck');		//传入参数为表单元素（由FCKeditor生成的input或textarea）的name
      oFCKeditor.BasePath='${cpath}/fckeditor/';	//指定FCKeditor根路径，也就是fckeditor.js所在的路径
      oFCKeditor.Height='260px';
      oFCKeditor.Width='580px';
      oFCKeditor.ToolbarSet='Demo';					//指定工具栏
	  oFCKeditor.ReplaceTextarea();
</script>
<script>
    /**
     * 检查项目资料维护
     */
	function doConfirm()
	{
		var form = document.theForm;

		var action = form['action'];
		var ntype = form['ntype'];
		if(ntype.value == "")
  		{
			alert('类型不能为空');
			ntype.select();
			return ;
		}

		var title = form['title'];
		if(title.value == null||title.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
  		{
			alert('标题不能为空');
			title.select();
			return ;
		}
		var nsort = form['nsort'];
		if(nsort.value == "")
  		{
			alert('板块不能为空');
			nsort.select();
			return ;
		}
		var fck = FCKeditorAPI.GetInstance("fck").GetXHTML("true");   
		var content = form['content'];
		content.value = fck;

		if(content.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
		{
			alert('内容不能为空');
			return ;
		}

		if(content.value.length > 2000)
		{
			alert('内容长度不能大于2000');
			return ;
		}

		var filepath = form['filepath'];
        if(filepath.value != "" && !check_loadfile(filepath))
        {
			return false;
        }	

		form.submit();
	}
	function my_getbyid(id)
	{

		 itm = null;
		 if (document.getElementById)
		 {
			itm = document.getElementById(id);
		 }
		 else if (document.all)
		 {
				itm = document.all[id];
		 }
		 else if (document.layers)
		 {
				itm = document.layers[id];
		 }		 
		 return itm;
	}
	function check_photo_size()
	{
		img_temp = my_getbyid('oFileChecker');
		var limit = parseInt(my_getbyid('max_file_size').value);
		if (img_temp.fileSize > limit) {
			alert("照片文件过大，请选择2M以下的文件上传");
			return false;
		}
	}
	function check_loadfile(filePicker)
	{
		var patn = /.jpg$|.jpeg$|.gif$/i;  
		if(patn.test(filePicker.value)) {
			img_temp = my_getbyid('oFileChecker');
			img_temp.src = filePicker.value;
		} else {

			var patn2 = /.doc$|.xls$|.ppt$|.rar$|.txt$/i;  
			if(!patn2.test(filePicker.value)) {			
				alert('您选择的不是合法的文件,支持文件格式：.jpg/.jpeg/.gif/.doc/.xls/.ppt/.rar/.txt，请重新选择');
				filePicker.value='';
				return false;
			}
		}
		return true;
	}

	/**
   * 根据具体请求设置各个组件状态	
   */
  function showState()
	{
		var action = '${theForm.action}';
		var form = document.theForm;		
		if(action == 'detail')
		{
           
			document.getElementById("back").style.display = "none";

		}
		else if(action == 'modifyPage' || action == 'update')
		{

			form['action'].value = 'adupdate';
		}else{

			form['action'].value = 'adadd';
		}

	}
	showState();


</script>

